home *** CD-ROM | disk | FTP | other *** search
- REM Bpp - Basic Pre-Processor
- REM © 1990 by Steven D. Kapplin
- REM Version 1.0 - 7/7/90
- REM
- REM Takes input file and builds a list of subroutines and functions,
- REM then reads a library file and extracts the required subroutines
- REM and functions and appends then to the input file.
- REM
- REM $OPTION Y+,k50,G-
- REM
- REM EXTERNAL
- REM SUB ParseCommandString
- REM FUNCTION testdelim%
- REM SUB explodes
- REM ENDEXTERNAL
- DECLARE FUNCTION testdelim%
-
- DIM SHARED words$(20)
- DIM FuncNames$(1001)
-
- DEFINT TRUE
- DEFINT FALSE
- DEFINT BufLen
-
- CONST BufLen=16384
-
- CALL ParseCommandString(COMMAND$,argv%,argc$())
-
- IF argv% = 0 OR UCASE$(argc$(1)) = "?" THEN
- CALL HelpMsg
- END
- END IF
- IF argv% = 1 THEN
- PRINT "No Lib File Specified"
- PRINT
- END
- END IF
- IF NOT FEXISTS(argc$(1)) THEN
- PRINT "Cannot Find Input File"
- PRINT
- END
- END IF
- IF NOT FEXISTS(argc$(2)) THEN
- PRINT "Cannot Find Lib File"
- PRINT
- END
- END IF
-
- POKE SYSTAB+33,0
-
- OPEN "i",#1,argc$(1),BufLen
-
- NumSubs%=0
-
- DO
- LINE INPUT #1,record$
- CALL explodes(record$," ,",words$(),count%)
- IF UCASE$(words$(2))="EXTERNAL" THEN
- DO
- LINE INPUT #1,record$
- CALL explodes(record$," ,",words$(),num%)
- test$=words$(2)
- IF UCASE$(test$)="ENDEXTERNAL" THEN EXIT DO
- INCR NumSubs%
- FuncNames$(NumSubs%) = words$(3)
- LOOP
- END IF
- LOOP UNTIL UCASE$(test$)="ENDEXTERNAL" OR EOF(1)
-
- IF NumSubs% = 0 THEN
- PRINT "No Subroutines or Functions Declared"
- PRINT
- CLOSE
- POKE SYSTAB+33,2
- END
- END IF
-
- CLOSE 1
-
- OPEN "i",#2,argc$(2),BufLen
-
- IF argv% < 3 THEN
- OPEN "a",#3,argc$(1),BufLen
- ELSE
- OPEN "o",#3,argc$(3),BufLen
- END IF
-
- DO WHILE NOT EOF(2)
- LINE INPUT #2,record$
- CALL explodes(record$," ,",words$(),count%)
- IF UCASE$(words$(1))="REM" THEN
- FOR i%=1 TO NumSubs%
- IF UCASE$(words$(2))=UCASE$(FuncNames$(i%)) THEN
- DO
- LINE INPUT #2,record$
- CALL explodes(record$," ,",words$(),count%)
- test$=UCASE$(words$(1))+" "+UCASE$(words$(2))
- PRINT #3,record$
- IF test$="END SUB" OR test$="END FUNCTION" THEN EXIT DO
- LOOP
- END IF
- NEXT i%
- END IF
- LOOP
-
-
- CLOSE
- POKE SYSTAB+33,2
- END
-
- SUB HelpMsg
- PRINT CHR$(27)+"[1m"+"Bpp - Basic Pre-Processor, Ver. 1.0"+CHR$(27)+"[0m"
- PRINT CHR$(27)+"[33m"+"© 1990 by Steven D. Kapplin"+CHR$(27)+"[31m"
- PRINT
- PRINT "Syntax: Bpp PgmFile LibFile [OutFile]"
- END SUB
-
- SUB ParseCommandString(s$,argv%,argc$(1))
- CALL explodes(s$," ,",words$(),count%)
- argv%=count%
- FOR i%=1 TO argv%
- argc$(i%)=words$(i%)
- NEXT i%
- END SUB
-
- REM Testdelim%
- 'utility routine used by some of these subroutines
- FUNCTION Testdelim%(s$,delim$,i%)
- IF (INSTR(delim$,MID$(s$,i%-1,1))=0) AND (INSTR(delim$,MID$(s$,i%,1))>0)
- Testdelim%= 1
- ELSE
- Testdelim%= 0
- END IF
- END FUNCTION
-
- REM explodes
- 'Same as exploden, except that strings are placed in array words$()
- SUB explodes(s$,delim$,words$(1),count%)
- l%=LEN(s$)
- IF l%=0 THEN
- EXIT SUB
- END IF
- i%=1
- count%=0
- WHILE (i%<l%) AND (INSTR(delim$,MID$(s$,i%,1))>0)
- INCR i%
- WEND
- ptr1%=i%
- IF (i%=1) THEN
- i%=2
- END IF
- WHILE i%<=l%
- IF Testdelim%(s$,delim$,i%)=1 THEN
- INCR count%
- ptr2%=i%-1
- words$(count%)=MID$(s$,ptr1%,ptr2%-ptr1%+1)
- WHILE (i%<l%) AND (INSTR(delim$,MID$(s$,i%,1))>0)
- INCR i%
- WEND
- ptr1%=i%
- END IF
- INCR i%
- WEND
- IF ptr1%<l% THEN
- INCR count%
- words$(count%)=MID$(s$,ptr1%)
- END IF
- END SUB
-
-
-
-